package com.king.java.tools.http.client.okhttp.impl;

import com.king.java.tools.http.HttpUtils;
import com.king.java.tools.http.client.okhttp.AbstractOkhttp;
import com.king.java.tools.http.entity.ConnectEntity;
import com.king.java.tools.http.entity.HttpJsonEntity;
import com.king.java.tools.http.entity.HttpMethod;
import okhttp3.OkHttpClient;
import okhttp3.Request;

/**
 * 描述: Get请求方式
 *
 * @author : sujinchen
 * @date : 2020/10/16
 */
public class GetHttp extends AbstractOkhttp implements HttpUtils {


    public GetHttp(OkHttpClient client, HttpJsonEntity entity) {
        super(client, entity);
    }

    public GetHttp(HttpJsonEntity entity) {
        super(entity);
        entity.setMethod(HttpMethod.GET);

    }

    /**
     * 执行请求
     *
     * @throws Exception
     */
    @Override
    public ConnectEntity run() throws Exception {
        Request request = new Request.Builder()
                .url(entity.getUrl())
                .get()
                .build();

        return synCall(request);
    }




}
